package tencent;

import org.jetbrains.annotations.NotNull;

import java.util.*;


public class Main2 {
    static int[]a,b,aCopy,temp;
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int t=scanner.nextInt();
        while (t--!=0){
            int n=scanner.nextInt();
            int len=n;
            a=new int[n];
            aCopy=new int[n];
            b=new int[n-1];
            for(int i=0;i<n;++i){
                a[i]=scanner.nextInt();
                aCopy[i]=a[i];
            }
            for(int i=0;i<n-1;++i){
                b[i]=scanner.nextInt();
            }
            Arrays.sort(a);
            println(len);
            for(int i=0;i<n-1;++i){
                int r=b[i]-1;
                aCopy[r]=Integer.MAX_VALUE;
                temp=aCopy;
                aCopy=a;
                a=temp;
                System.out.println("a数组的值：");
                for(int j=0;j<a.length;++j){
                    System.out.print(a[j]+" ");
                }
                System.out.println("------------------");
                Arrays.sort(a);
                len--;
                println(len);
            }
        }
    }

    private static void println(int len) {
        if(len%2==0){
            System.out.printf("%.1f ",((double)a[len/2]+(double) a[len/2-1])/2);
        }else{
            System.out.printf("%d ",a[len/2]);
        }
    }
}
